﻿using System;
using System.Text;
using System.IO;
using System.Net;
using System.Web;


public class GenerateHTML
{
    public static string generateInfoHTML(string url,string path)
    {
        string str = null;
        WebResponse response = null;
        StreamReader reader = null;
        StreamWriter sw = null;
        //try
        //{

            //string paramId = type.Equals("companyInfo") ? "comId" : "jobsId";
            //string pageName = type.Equals("companyInfo") ? "companyInfo" : "jobInfoTemp";
            //string url = string.Format("../allergy/{0}.aspx?{1}={2}", "lore", paramId, id);
            //string url = string.Format("http://localhost/allergy/{0}/{1}.aspx",folder,aspNm);
            WebRequest request = WebRequest.Create(url);
            response = request.GetResponse();
            reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            str = reader.ReadToEnd();
            //sw = new StreamWriter(string.Format(@"D:\wwwroot\JobSearch\web\{0}\{1}.html", type, id), false, Encoding.GetEncoding("gb2312"));
            //sw = new StreamWriter(string.Format(HttpContext.Current.Server.MapPath("../allergy/folder/59.html"), false, Encoding.GetEncoding("utf-8")));
            sw = new StreamWriter(path, false, Encoding.GetEncoding("utf-8"));
            sw.Write(str);
        //}
        //catch (Exception e)
        //{

        //}
        //finally
        //{
            response.Close();
            reader.Close();
            reader.Dispose();
            sw.Close();
            sw.Dispose();
        //}
        return str;
    }
}

